package hu.jonas.allunit.views;

import hu.jonas.allunit.AllUnitPlugin;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.swt.graphics.Image;

public class IconProvider {

	private Map<String, Image> icons = new HashMap<String, Image>();

	public Image getIcon(String iconName) {

		Image image = icons.get(iconName);
		if (image != null) {
			return image;
		} else {
			Image newImage = AllUnitPlugin.getImageDescriptor(iconName)
					.createImage();

			icons.put(iconName, newImage);

			return newImage;
		}
	}

	public void registerIcon(String iconName, Image image) {
		icons.put(iconName, image);
	}

}
